package org.example.struct.array2;

import com.alibaba.fastjson2.JSON;

/**
 * @author liyishan
 * @date 2023/10/13 10:00
 * @apiNote
 */

public class Test00667ConstructArray {


    public static void main(String[] args) {
        int[] res = test(5, 3);
        System.out.println(JSON.toJSON(res));
    }

    /**
     *
     * @param n
     * @param k
     * @return
     */
    public static int[] test(int n, int k) {
        int[] res = new int[n];
        int idx = 0;
        for(int i = 1; i < n-k; i++){
            res[idx] = i;
            idx++;
        }
        for(int i = n-k,j = n; i<=j;i++,j--){
            res[idx] = i;
            idx++;
            if(i!= j){
                res[idx] = j;
                idx++;
            }
        }
        return res;
    }
}
